import Vue from 'vue'
import VueRouter from 'vue-router'

const Home = () => import('pages/home')
const Article = () => import('pages/article')
const Index = () => import('pages/index')
const Login = () => import('pages/login')
const Register = () => import('pages/register')
const Sendblog = () => import('pages/sendBlog')
const md = () => import('../components/mkEdit')
const Github = () => import('../components/github')
const Community = () => import('pages/community')
const UserCenter = () => import('pages/userCenter')

Vue.use(VueRouter)

const routes = [
  {

    path: '/',
    name: 'home',
    component: Home,
    redirect: 'index',
    children: [
      {
        path: 'index',
        name: 'index',
        component: Index,
        meta: {
          keepAlive: true
        }
      },
      {
        path: 'article/:tid/:clickcount',
        name: 'article',
        component: Article,
        meta: {
          keepAlive: false
        }
      },
      {
        path: 'sendblog',
        name: 'sendblog',
        component: Sendblog,
        meta: {
          keepAlive: false
        }
      },
      {
        path: 'community',
        name: 'community',
        component: Community,
        meta: {
          keepAlive: true
        }
      },
      {
        path: 'github',
        name: 'github',
        component: Github
      },
      {
        path:'usercenter',
        name:'usercenter',
        component:UserCenter
      }

    ]
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  {
    path: '/register',
    name: 'register',
    component: Register
  },
  {
    path: '/md',
    name: 'md',
    component: md,
    meta: {
      keepAlive: true
    }
  },

  // {
  //   path: '/comehome',
  //   name: 'comehome',
  //   component: communityHome,
  //   redirect:'community',
  //   children:[
  //     {
  //       path: '/community',
  //       name: 'community',
  //       component: Community
  //     },
  //   ]

  // },

]

const router = new VueRouter({
  linkActiveClass: 'router-link-active',
  routes,
  scrollBehavior(to, from, savedPosition) {
    return { x: 0, y: 0 }
  }
})

export default router
